package com.quanxiaoha.weblog.admin.controller;

import com.quanxiaoha.weblog.admin.model.vo.comment.FindCommentPageListReqVO;
import com.quanxiaoha.weblog.admin.model.vo.comment.UpdateCommentStatusReqVO;
import com.quanxiaoha.weblog.admin.service.AdminCommentService;
import com.quanxiaoha.weblog.common.Response;
import com.quanxiaoha.weblog.common.aspect.ApiOperationLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class AdminCommentController {

    @Autowired
    private AdminCommentService commentService;
//
    @PostMapping("/comment/list")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @ApiOperationLog(description = "查看文章下的评论列表")
    public Response findCommentPageList(@RequestBody @Validated FindCommentPageListReqVO findCommentPageListReqVO) {
        return commentService.findCommentPageList(findCommentPageListReqVO);
    }

    @PostMapping("/comment/update")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    @ApiOperationLog(description = "删除或者修改评论")
    public Response updateCommentStatus(@RequestBody @Validated UpdateCommentStatusReqVO updateCommentStatusReqVO) {
        return commentService.updateCommentStatus(updateCommentStatusReqVO);
    }
}